package cn.zjxiliu.lib_login;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import cn.zjxiliu.lib_config.ConfigSDK;
import cn.zjxiliu.lib_login.server.HttpManager;
import cn.zjxiliu.lib_login.server.callback.LoginCallback;
import cn.zjxiliu.lib_login.server.response.LoginResponse;
import cn.zjxiliu.lib_login.ui.login.LoginViewImpl;

/**
 * Created by jessie on 2018/11/21.
 */

public class LoginSDK {

    private static LoginSDK loginSDK = new LoginSDK();

    private LoginSDK(){}

    private Context context;

    private LoginConfig loginConfig;


    private LoginSDKListener listener;

    public LoginSDKListener getListener() {
        return listener;
    }

    public void setListener(LoginSDKListener listener) {
        this.listener = listener;
    }

    public Context getContext() {
        return context;
    }

    public LoginConfig getLoginConfig() {
        return loginConfig;
    }

    public static LoginSDK getInstance(){
        return loginSDK;
    }



    public LoginSDK init(Context context, String baseRequestUrl){
        this.context = context;
        loginConfig = ConfigSDK.getInstance().getConfig(context, LoginConfig.class);
        if(!TextUtils.isEmpty(baseRequestUrl))
            loginConfig.setBaseRequestUrl(baseRequestUrl);
        HttpManager.getInstance().init(loginConfig.getBaseRequestUrl());
        return this;
    }

    public void start(Context context){
        context.startActivity(new Intent(context, LoginViewImpl.class));
    }


    public void loginByToken(String token, LoginCallback callback){


    }


    public void refreshToken(LoginCallback callback){


    }
}
